package phonecompany;

import java.rmi.Remote;
import java.util.Map;

import phonecompany.account.Account;
import phonecompany.account.PayAsYouGoAccount;
import phonecompany.account.PhoneAccount;
import phonecompany.account.UnlimitedCallsAccount;
import phonecompany.customer.Customer;
import phonecompany.phone.Phone;
import phonecompany.phone.PhoneNumber;

/**
 * This interface is used to define the main functions of the PhoneManger.It
 * also used to help deploy the RMI appliocation.
 * 
 * @since Oct 30, 2011
 * @author <a href="mailto:zexpp5@gmail.com">Zexu.Lin</a>
 * @version $Id: PhoneManagerService.java 27 2011-10-30 18:35:47Z
 *          zexpp5@gmail.com $
 * 
 */
public interface PhoneManagerService extends Remote {
	/**
	 * To get the related Account by phone number.
	 * 
	 * @param phoneNumber
	 * @return related Account
	 * @description
	 * 
	 * @author <a href="mailto:zexpp5@gmail.com">Zexu.Lin</a>
	 * @update Oct 30, 2011 6:44:03 PM
	 */
	public abstract Account getAccount(PhoneNumber phoneNumber);

	/**
	 * To get current collection of issued Account which are stored in a
	 * HashMapo.
	 * 
	 * @return a collection of all issued Account.
	 * @description
	 * 
	 * @author <a href="mailto:zexpp5@gmail.com">Zexu.Lin</a>
	 * @update Oct 30, 2011 6:44:41 PM
	 */
	public abstract Map<PhoneNumber, Account> getAllAccount();

	/**
	 * For customers to return their phones. When a phone is returned, its state
	 * turns to blocked.
	 * 
	 * @param phoneNumber
	 * @description
	 * 
	 * @author <a href="mailto:zexpp5@gmail.com">Zexu.Lin</a>
	 * @update Oct 30, 2011 6:45:53 PM
	 */
	public abstract void returnPhone(PhoneNumber phoneNumber);

	/**
	 * To delete an account by its phone number . The account could only be
	 * deleted when its state is blocked.
	 * 
	 * @param phoneNumber
	 * @return true:success,false:faild
	 * @description
	 * 
	 * @author <a href="mailto:zexpp5@gmail.com">Zexu.Lin</a>
	 * @update Oct 30, 2011 6:47:11 PM
	 */
	public abstract boolean deleteAccount(PhoneNumber phoneNumber);

	/**
	 * This method is used to issue a new phone for a customer, it generate a
	 * new Phone number and a account with assigned type , and also associates
	 * the them together.
	 * 
	 * @param c
	 *            customer to get the account
	 * @param pn
	 *            a new generated phone number
	 * @param accountType
	 *            payasyougo or unlimitedcalls
	 * @return a related account
	 * @description
	 * 
	 * @author <a href="mailto:zexpp5@gmail.com">Zexu.Lin</a>
	 * @update Oct 30, 2011 6:49:38 PM
	 */
	public abstract Account issueNewPhone(Customer c, PhoneNumber pn,
			String accountType);

	/**
	 * When phone manager is deployed by RMI, this method is used to get the
	 * stored Account for customer.
	 * 
	 * @param phoneNumber
	 * @return related account
	 * @description
	 * 
	 * @author <a href="mailto:zexpp5@gmail.com">Zexu.Lin</a>
	 * @update Oct 30, 2011 6:53:30 PM
	 */
	public abstract Account echoPhoneAccount(String phoneNumber);
}
